home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DragPriv.cpp
-
- Contains: Definition of Private classes for ODDragAndDrop.
-
- Owned by: Vincent Lo
-
- Copyright: © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <4> 5/13/96 DH 1332488 - 1.0.x:User break dragging Edition
- file into an OpenDoc window.
- 1305572 - 1.1MRD:[Cyberdog]Dragging
- multiple items *really* slow.
- 1314704 - 1.0.x: Enourmous performance hit
- when dragging numb erous items over
- windows.
- <3> 5/1/96 JA 1314704: Allow ODMemDragItem to use
- pre-existing container.
- <2> 3/15/96 DH 1287259 - 1.0.2 Don't get back what I put
- in the scrapbook. Changed ODMemContainer so
- that it has a constructor that makes a new
- container given a container handle.
- <7> 9/6/95 VL 1274572: Added GetFinderInfo and
- GetIconFamilyFromFile.
- <6> 5/25/95 jpa List.h --> LinkList.h [1253324]
- <5> 12/13/94 VL 1203627,1200603,1203451,1198037,1194537,119
- 4755,1186815: Bug fixes.
- <4> 9/29/94 RA 1189812: Mods for 68K build.
- <3> 9/23/94 VL 1184272: ContainerID is now a sequence of
- octets.
- <2> 7/26/94 VL Got rid of dependency on Bento Container
- Suite.
- <1> 7/21/94 VL first checked in
-
- To Do:
- In Progress:
-
- */
-
- #ifndef _DRAGPRIV_
- #define _DRAGPRIV_
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #ifndef _PLFMDEF_
- #include <PlfmDef.h>
- #endif
-
- #ifndef _LINKLIST_
- #include <LinkList.h>
- #endif
-
- //==============================================================================
- // Forward declaration
- //==============================================================================
-
- class ODStorageSystem;
- class ODContainer;
- class ODDocument;
- class ODDraft;
- class PlatformFile;
- class ODStorageUnit;
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- #define kODUserPromiseFlavor 0x66696c65 // 'file'
- //#define kODBentoFlavor 0x626E746F // 'bnto'
- // The Bento container flavor was changed to odcn so we have compatibility with
- // the clipboard.
- #define kODBentoFlavor 0x6F64636E // 'odcn'
- #define kODPromiseFlavor 0x70726D73 // 'prms'
- #define kODPromiseDesc 0x70726D73 // 'prms'
- #define kODScrapTypestyl 0x7374796c // 'styl'
- #define kODScrapTypestxt 0x73747874 // 'stxt'
- #define kODScrapTypeTEXT 0x54455854 // 'TEXT'
-
- #define kODDropHasLeftSourceFrameMask ~kODDropIsInSourceFrame
- #define kODDragHasLeftSourcePartMask ~(kODDropIsInSourceFrame | kODDropIsInSourcePart)
-
- // #define kODDestinationFileSpec 'dfss'
- // #define kODSourceFileSpec 'sfss'
- // #define kODPreReplaceFileEventID 'prfl'
- // const FourCharCode kODReplaceFileEventID = 'rfl ';
- // #define kODSession 'sess'
-
- #define kODDestinationFileSpec 'DFSS'
- #define kODSourceFileSpec 'SFSS'
- #define kODReplaceFileEventID 'RFL '
- #define kODSession 'SESS'
-
- const ODULong kODInitialNumEntries = 8;
-
- #if ODDebug
- // #define ODDebug_DragAndDrop 1
- #endif
-
- //#define IsOpenDocDocument(osType) ((osType != 'APPL') && (osType != 'shlb'))
- #define SetPasteAsAttribute(self, ev, m) do {if ((m & cmdKey) && IsFrontProcess()) self->SetAttributes(ev, self->GetAttributes(ev) | kODDropIsPasteAs);} while (0)
-
- //==============================================================================
- // Scalar Types
- //==============================================================================
-
- typedef struct {
- ODPart *sourcePart;
- ODStorageUnitView *destSUView;
- } ODPromiseDesc;
-
- //==============================================================================
- // Function prototype
- //==============================================================================
- static ODBoolean DragItemHasFlavor(ODPlatformDragReference theDrag, ItemReference itemID, OSType theType);
- static ODBoolean IsOpenDocDocument(HFSFlavor* hfsFlavor);
-
- void GetFinderInfo(Environment* ev, ODStorageUnit* su, PlatformFile* file);
- void GetIconFamilyFromFile(Environment* ev, ODStorageUnit* su, PlatformFile* file);
-
- //==============================================================================
- // ODDragItem
- //==============================================================================
- class ODDragItem
- {
- public:
-
- ODDragItem(ODStorageSystem *storage, ODBoolean IsForeignDataSU,
- ODPlatformDragReference currentDrag, ItemReference currentDragItemRefNumber,
- HFSFlavor* theHFSFlavor);
- ODVMethod ~ODDragItem() {}
- ODNVMethod void Initialize(Environment* ev) {}
- ODVMethod void Open(Environment* ev);
- ODVMethod void Close(Environment* ev);
- ODVMethod ODDraft* GetDraft(void) { return fDraft; }
- ODVMethod ODStorageUnit* GetStorageUnit(Environment* ev) { return fSU; }
-
- protected:
- void AddFinderInfoToSU( Environment* ev );
- void AddMacOSTypeInfoToSU( Environment* ev );
-
- ODStorageUnit* fSU;
- ODPlatformDragReference fCurrentDrag; // A reference to the drag currently in
- // in progress.
- ItemReference fCurrentDragItemRefNumber;
- HFSFlavor* fHFSFlavorPtr;
- // This and the reference above are
- // used to append an HFS item to the Drag container.
- // Apparently, this is used to allow parts to act like
- // the Finder, and access the Finder info of items
- // dragged into it.
- ODStorageSystem* fStorageSystem;
- ODContainer* fContainer;
- ODDocument* fDocument;
- ODDraft* fDraft;
- };
-
- class ODMemDragItem : public ODDragItem
- {
- public:
- ODMemDragItem(ODStorageSystem *storage, ODDraft* theDraft, ODBoolean IsForeignDataSU,
- ODPlatformDragReference currentDrag, ItemReference currentDragItemRefNumber,
- HFSFlavor* theHFSFlavor) : ODDragItem(storage, IsForeignDataSU,
- currentDrag, currentDragItemRefNumber, theHFSFlavor)
- { fContainerHandle = 0; fDraft = theDraft; };
-
- ODMemDragItem( ODStorageSystem *storage, ODHandle containerH, ODBoolean IsForeignDataSU,
- ODPlatformDragReference currentDrag, ItemReference currentDragItemRefNumber,
- HFSFlavor* theHFSFlavor) : fContainerHandle(containerH) ,
- ODDragItem(storage, IsForeignDataSU, currentDrag,
- currentDragItemRefNumber, theHFSFlavor) {};
-
- ~ODMemDragItem();
- void Initialize(Environment* ev);
- void Open(Environment* ev);
- void Close(Environment* ev);
- ODHandle GetContainerHandle( void ) { return fContainerHandle; }
- ODStorageUnit* GetStorageUnit(Environment* ev);
-
- ODHandle fContainerHandle;
- };
-
- class ODFileDragItem : public ODDragItem
- {
- public:
- ODFileDragItem(ODStorageSystem *storage, ODBoolean IsForeignDataSU,
- ODPlatformDragReference currentDrag, ItemReference currentDragItemRefNumber,
- HFSFlavor* theHFSFlavor)
- : fContainerID(0), ODDragItem(storage, IsForeignDataSU, currentDrag,
- currentDragItemRefNumber, theHFSFlavor) {};
- ~ODFileDragItem();
- void Initialize(Environment* ev, ODContainerID* file);
- ODStorageUnit* GetStorageUnit(Environment* ev);
-
- private:
- ODContainerID* fContainerID;
- };
-
-
- //==============================================================================
- // ODDragLink
- //==============================================================================
- class ODDragLink : public Link
- {
- public:
- ODDragLink(ODDragItem *theItem, ODBoolean cleanup);
- ~ODDragLink();
-
- ODDragItem *fItem;
- ODBoolean fCleanup;
- };
-
- //==============================================================================
- // Implementation
- //==============================================================================
- ODBoolean DragItemHasFlavor(ODPlatformDragReference theDrag, ItemReference itemID, OSType theType)
- {
- ODBoolean result = kODFalse;
- ODUShort count;
- ODUShort j;
- OSType itemType;
-
- CountDragItemFlavors(theDrag, itemID, &count);
- for (j = 1; j <= count; j++)
- {
- OSErr err = GetFlavorType(theDrag, itemID, j, &itemType);
- if ( err != noErr )
- break;
- if (itemType == theType)
- {
- result = kODTrue;
- break;
- }
- }
-
- return result;
- }
-
-
- #endif // _DRAGPRIV_
-